shared float4x4 matViewProjection:VIEW_PROJECTION;
shared float4x4 matWorld:WORLD;
shared float4x4 matView:VIEW;
shared float4     diffuseColor:DIFFUSE_COLOR;
texture diffuseMap:DIFFUSE_MAP;

int g_nGrads;
sampler diffuseMapSampler = 
sampler_state
{
    Texture     = <diffuseMap>;
    MipFilter  = LINEAR;
    MinFilter  = LINEAR;
    MagFilter = LINEAR;
};
struct VS_INPUT
{
    float4 position : POSITION0; 
    float3 normal   : NORMAL;
    float4 color 		: COLOR;
    float2 texcoord : TEXCOORD0;
};
struct VS_OUTPUT
{
    float4 position : POSITION0;
    float3 normal   : TEXCOORD0;
    float2 texcoord : TEXCOORD1;
    float   height : TEXCOORD2;
    float4 color    : COLOR;
};
VS_OUTPUT vs_main(VS_INPUT _input)
{
  VS_OUTPUT _out;
  float4x4 mat00 = mul(matViewProjection ,matView );
  _out.position = mul(_input.position,matView );
  _out.position = mul(_out.position,matViewProjection );
  _out.normal   = mul(_input.normal,matWorld );
  _out.height     = _input.position.y;
  _out.texcoord	= _input.texcoord;
  _out.color    = _input.color;
  return _out;
}

struct PS_INPUT
{
	float3  normal:	 TEXCOORD0;
  	float2  texcoord:TEXCOORD1;
    float   height : TEXCOORD2;
  	float4  color:	 COLOR;
};
float4 ps_main(PS_INPUT _input):COLOR0
{
	float4	xxx;
	
	if( 0 < _input.height && _input.height <= 50 )
	{
	    float temp;
	    temp = float(_input.height)/50.0f;
		xxx	=	float4(0.0f,0.0f,temp,1.0f);
	}
	else if( 50 < _input.height && _input.height <= 100 )
	{
		float temp;
	    temp = float(_input.height - 50)/50.0f;
		xxx	=	float4(0.0f,temp,1.0f,1.0f);
	}
	else if( 100 < _input.height && _input.height <= 150 )
	{
		float temp;
	    temp = float(150 - _input.height )/50.0f;
		xxx	=	float4(0.0f,1.0f,temp,1.0f);	
	}
	else if( 150 < _input.height && _input.height <= 200 )
	{
		float temp;
	    temp = float( _input.height - 120 )/40.0f;
		xxx	=	float4(temp,1.0f,0.0f,1.0f);
	}
	else if( 200 < _input.height && _input.height <= 255 )
	{
		float temp;
	    temp = float( 255 - _input.height  )/55.0f;
		xxx	=	float4(1.0f,temp,0.0f,1.0f);
	}
	return xxx;
}

technique vs_2_0_ps_2_0
{
    pass P0
    {
    	CullMode	=	CCW;
        // vertex shader
        VertexShader = compile vs_3_0 vs_main();
        // pixel shader
			PixelShader  = compile ps_3_0 ps_main();
    }
}
 